<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }
        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
        #title_name{
            padding-top: 10px;
            padding-left: 10px;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>首页
            <small>公司分布图</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>公司分布图</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div id="title_name">
            <span @click="showMap()"><font>分布图&nbsp;&nbsp;&nbsp;&nbsp;</font></span>

            <font color="#00bfff">详细信息</font>
            <hr width="100%"/>
        </div>
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="公司地址" v-model="pagination.queryString" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
                <el-button type="primary" class="butT" @click="handleCreate()">新建</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="companyList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="address_name" label="公司地址" align="center"></el-table-column>
                <el-table-column prop="longitude" label="所在经度" align="center"></el-table-column>
                <el-table-column prop="latitude" label="所在纬度" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button size="mini" type="danger" @click="deleteAddress(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>

            <!-- 新增标签弹层 -->
            <div class="add-form">
                <el-dialog title="新增公司地址" :visible.sync="dialogFormVisible">

                    <!--<object data="map_add.html" type="text/x-scriptlet" width="100%" height="670px"></object>-->
                    <iframe align="center" width="100%" height="670" src="map_add.html"  frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>

                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    var vue = new Vue({
        el: '#app',
        data:{
            activeName:'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize:10,
                total:100,
                queryString:null,
            },
            companyList: [],//列表数据
            dialogFormVisible: false,//控制添加窗口显示/隐藏
        },
        // 钩子函数，Vue对象一创建，就执行该函数
        created() {
            this.findPage();
        },
        methods: {
            //分页查询
            findPage() {
                axios.post("/company/findPage.do",this.pagination).then(resp=>{
                    //分页数据回显
                    this.companyList = resp.data.data.rows;
                    this.pagination.total = resp.data.data.total;
                })
            },
            //展示地图上公司的位置，并标记出来
            showMap(){
                location.href = '/pages/scattergram.html';
            },
            // 重置表单
            resetForm() {
                // 让formData的值为空，就能实现表单重置
                this.formData={};
            },
            // 弹出添加窗口
            handleCreate() {
                // 点击新建按钮之后，将dialogFormVisible设置为true，显示表单
                this.dialogFormVisible=true;
                // 显示表单后，重置表单，不让上一次操作的数据留下
                this.resetForm();
                // 每次让表单显示在 “新增套餐基本信息” 栏

                // 发送ajax请求，获取所有的检查组数据
                // axios.post("/checkgroup/findAll.do").then((resp) =>{
                //     // 获取成功，展示数据
                //     this.tableData=resp.data;
                // });
            },
            //切换页码
            handleCurrentChange(currentPage) { // currentPage：表示翻页之后的新页码
                // 将翻页之后的新页码，赋值个pagination中的当前页码
                this.pagination.currentPage=currentPage;
                // 赋值后再次分页查询，达到分页效果
                this.findPage();
            },
            deleteAddress(row){
                this.$confirm('确认删除这条地址吗','提示',{type:"warning"})
                    .then(() => {
                        axios.get("/company/delete.do?id="+row.id)
                            .then(resp => {
                                if (resp.data.flag) {
                                    //删除成功
                                    this.$message({
                                        type: 'success',
                                        message: resp.data.message
                                    })
                                }else{
                                    //删除失败
                                    this.$message({
                                        type: 'warning',
                                        message: resp.data.message
                                    })
                                }
                            }).finally(() => {
                            this.findPage();
                        })
                    }).catch(() => {
                    this.$message({
                        type:'info',
                        message:'操作已取消',
                    })
                })
            }
        }
    })
</script>
</html>
